package br.edu.unifei.cct720.alieninvasion.main;

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import br.edu.unifei.cct720.alieninvasion.main.gui.Game;
import br.edu.unifei.cct720.alieninvasion.utils.Messages;
import br.edu.unifei.cct720.trabalho07.utils.Mensagem;

/**
 * Class used to execute the game application
 * 
 * @author Felipe Knappe
 *
 */
public class Main {

	/**
	 * Method responsible to perform application execution call
	 * 
	 * @param args The arguments passed throw the call
	 * 
	 */
	public static void main(String args[]) {

		// Initializing a new GUI instance
		final Game game = new Game("Alien Invasion");

		// Handle window disposing event
		game.addWindowListener(new WindowAdapter() {
			public void windowClosing(WindowEvent e) {
				if(Messages.confirmMessage(
						game, 
				"Do you really want to close game?")
				) {

					game.dispose();
					System.exit(0);
				}
			}
		});
	}
}
